// include/random_text.h
#ifndef RANDOM_TEXT_H
#define RANDOM_TEXT_H

#include <string>
#include <unordered_map>
#include <vector>
#include <utility>



struct pair_hash {
    std::size_t operator()(const std::pair<std::string, std::string>& p) const {
        return std::hash<std::string>()(p.first) ^ (std::hash<std::string>()(p.second) << 1);
    }
};

class MarkovModel {
public:

    MarkovModel(int state_size = 2);


    bool train(const std::string& file_path);


    std::string generate_sentence(int max_words = 20, unsigned int seed = 0);

private:
    int state_size_;
    std::unordered_map<std::pair<std::string, std::string>, std::vector<std::string>, pair_hash> transitions_;
    std::vector<std::pair<std::string, std::string>> starting_keys_;
};


std::string generate_random_sentence(MarkovModel& model, int max_words = 20, unsigned int seed = 0);

#endif // RANDOM_TEXT_H
